/**
 * Created by webrx on 2024/4/29.
 */

//导入的@utils/request.ts
import {get, post, del, put, patch} from '@/utils/request'
import {ElLoading, ElMessage} from 'element-plus'


// 登录api  login
export const login = async () => {
    try {
        const {data, meta} = await post('login', {username: 'admin', password: '123456'})
        console.log(data)
        console.log(meta)
        const {username, token} = data
        localStorage.setItem('token', token)
        console.log(username)
        console.log(token)
        ElMessage.success(meta.msg)
    } catch (err) {
        ElMessage.error('网络错误')
    }
}

// 获取所有用户
export const getUsers = async (params: any) => {
    try {
        const res = await get('users', params)
        console.log(res.data)
        console.log(res.meta)
    } catch (err) {
        ElMessage.error('网络错误')
    }
}
